Friends of OpenJDK Today

Getting Started with Deep Learning in Java Using Deep Netts (Part 2)

August 03, 2022

Author(s)

  • Avatar photo
    Zoran Sevarac

    Zoran is an artificial intelligence software developer, entrepreneur, Java Champion, and researcher. He's the creator of the popular and award winning educational Java open source neural network software Neuroph and ... Learn more

Deep Netts is a deep learning development toolkit that enables Java developers to easily add modern AI to their apps. It provides a deep learning IDE and a Java-native deep learning library for embedding AI models into Java apps.

In part 1, we looked at the Deep Netts Community Edition, which is capable of solving basic machine learning problems, and provides a standard set of features.

If you have more complex challenges, more data, and need better performance or just want friendly tools to quickly try and learn AI, you should take a look at Deep Netts Professional Edition.

Download & Installation

  1. Download Deep Netts from the official download page.
  2. Run Maven installation scripts provided by the downloaded package to install Deep Netts JARs into your local Maven repo.

A detailed step by step installation guide is available here.

Note that the free download is fully functional and that it can be used for development. If you build a working prototype, it is possible to get a free low-volume production license.

Example: Hand-Written Digits Recognition

This example shows how to build a deep learning model in Java that can learn how to classify images, given the set of example images with corresponding category labels/classes.

The data set consists of 60000 images of handwritten digits. Each image is size of 28x28 pixels. Few sample images are shown in the image below.

As you can see, there is a lot of variation in each digit, and it would be impossible to come out with some set of rules to recognize these digits - that's why we want to build a model which will be capable to extract and learn patterns from these examples.

The following code snipet loads images and corresponding labels that will be used to train/build the model.

ImageSet imageSet = new ImageSet(imageWidth, imageHeight);
imageSet.setInvertImages(true); 
imageSet.loadLabels(new File(labelsFile));
imageSet.loadImages(new File(trainingFile), 1000);

Convolutional neural networks are type of deep learning models which are capable to learn patterns in image pixels, and they will be used to demonstrate how Deep Netts can be used to accomplish this.

The image bellow shows the architecture of a typical convolutional neural network which consists of a few blocks of convolutional and pooling operations which perform feature detection/extraction, followed by the fully connected layers that perform classification.

The convolutional neural network can be created using the following Java code snippet in Deep Netts, using ConvolutionalNetwork class and it's corresponding builder.

// create convolutional neural network architecture
ConvolutionalNetwork neuralNet = ConvolutionalNetwork.builder()
            .addInputLayer(imageWidth, imageHeight)
            .addConvolutionalLayer(12, 5)
            .addMaxPoolingLayer(2, 2)
            .addFullyConnectedLayer(60)
            .addOutputLayer(labelsCount, ActivationType.SOFTMAX)
            .hiddenActivationFunction(ActivationType.RELU)
            .lossFunction(LossType.CROSS_ENTROPY)
            .randomSeed(123)
            .build();

Full source of this example with comments and more detailed explanation is available at GitHub and step by step tutorial.

Deep Learning IDE

Deep Netts IDE provides visual tools and wizards that simplify building, debugging, and experimenting with various AI-related development activities.

Not only does it increases productivity in AI development, but it also helps developers to better understand the functioning of deep learning and problems they experience.

It is built on top of Apache NetBeans, following proven practices in UX and architecture.

Differences Compared to Community Edition

The professional edition provides tools and features that can significantly improve and simplify building your AI models.

This includes:

  1. Multi threading support. Faster execution, both training and inference
  2. IDE with visual tools and debugger. Highly productive environment, enables understanding and fixing models and data.
  3. Improved algorithms. And other features that provide faster training and higher accuracy.

Links

Related Articles

View All

Author(s)

  • Avatar photo
    Zoran Sevarac

    Zoran is an artificial intelligence software developer, entrepreneur, Java Champion, and researcher. He's the creator of the popular and award winning educational Java open source neural network software Neuroph and ... Learn more

Comments (0)

Your email address will not be published. Required fields are marked *

Highlight your code snippets using [code lang="language name"] shortcode. Just insert your code between opening and closing tag: [code lang="java"] code [/code]. Or specify another language.

Save my name, email, and website in this browser for the next time I comment.

Subscribe to foojay updates:

https://foojay.io/feed/
Copied to the clipboard